package com.lse_api.config;

import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;

import javax.servlet.MultipartConfigElement;

/**
 * 文件上传大小限制
 *
 * @author 祁雪
 */
@Configuration
public class FileMultipartConfig {

    /**
     * 配置文件上传大小
     */
    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        //  单个数据大小 30MIB
        factory.setMaxFileSize(DataSize.ofBytes(31457280));
        /// 总上传数据大小 500MIB
        factory.setMaxRequestSize(DataSize.ofBytes(524288000));
        return factory.createMultipartConfig();
    }

}
